package com.santu.edu.supporter.biz.order.helpbuy.service.impl;

import com.santu.edu.supporter.biz.order.common.pojo.enums.OrderStatusEnum;
import com.santu.edu.supporter.biz.order.helpbuy.dao.HelpByOrderDao;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.dto.HelpBuyOrderDTO;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.params.HbOrderAddParam;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.params.HbOrderUpdateParam;
import com.santu.edu.supporter.biz.order.helpbuy.service.HelpBuyService;
import com.santu.edu.supporter.util.PageData;
import com.santu.edu.supporter.util.UuidUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
@Service
@RequiredArgsConstructor
public class HelpBuyServiceImpl implements HelpBuyService {


    private final HelpByOrderDao helpByOrderDao;

    @Override
    public Boolean addOrder(HbOrderAddParam addParam) {
        String orderId = UuidUtils.getOrderId();
        HelpBuyOrderDTO dto = HelpBuyOrderDTO.createItem(addParam, orderId);
        helpByOrderDao.addOrder(dto);
        return true;
    }

    @Override
    public Boolean updateOrder(HbOrderUpdateParam updateParam) {
        HelpBuyOrderDTO dto = HelpBuyOrderDTO.createItem(updateParam);
        helpByOrderDao.updateOrder(dto);
        return true;
    }

    @Override
    public Boolean cancelOrder(String orderId) {
        helpByOrderDao.cancelOrder(orderId);
        return true;
    }

    @Override
    public PageData<HelpBuyOrderDTO> getOrderList(String schoolId, String userId, Integer orderType, int page, int size) {
        return helpByOrderDao.getOrderList(schoolId, userId, orderType, page, size);
    }

    @Override
    public void updateOrderStatus(String orderId, OrderStatusEnum orderStatus,OrderStatusEnum nowOrderStatus) {
        helpByOrderDao.updateOrderStatus(orderId, orderStatus,nowOrderStatus);
    }


}
